//Client Connection list Manager
//
// Created: Daly 2012-04-01

#include "ax_common.h"
#include <xnt_event.h>

#ifndef _CONN_MGR_H_
#define _CONN_MGR_H_

class ConnectMgr
{
public:
	ConnectMgr();
	ConnectMgr(int n);
	~ConnectMgr();	
	void alloc(int n);
	
	int alloc_connect(int sockfd, int type);
	void free_connect(int vfd);
	AxConnection* get_connect(int vfd);

private:

	int _count;  //amount of valid connection
	int _max;    //upper limit of _count
	int _max_vfd;

	AxConnection *_free_head;
	AxConnection *_pool;   //connection array 
};

//listen mgr
class ListenMgr
{
public:
	enum {OUTER_LISTEN=0, INNER_LISTEN=1};
	ListenMgr();
	~ListenMgr();
	AxListen* get_listener(int type);	
private:
	AxListen outer;
	AxListen inner;	
};

#endif
